import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'
import axios from 'axios'
import './assets/fonts/font.css'

Vue.use(ViewUI);
Vue.config.productionTip = false;
Vue.prototype.$http=axios;
// 路由守卫,对每一次跳转都会拦截，并判断是否有权利访问目标页面
router.beforeEach((to,from,next)=>{
  if(to.meta.requireAuth){
    if(window.sessionStorage.getItem('userInfo')){
      next();
    }else{
      next({
        path:'/login',
        query:{redirect:to.fullPath}
      });
    }
  }else{
    next();
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')